package backendapi

import (
	// "bp/cache"
	"bp/conf"
	"bp/db"

	// "bgs/grpc/client"
	"bp/internal/rpcserver/backendapi/coupon_imp"
	"bp/internal/rpcserver/backendapi/off_imp"
	"bp/internal/service/com"
	"bp/internal/service/entity"
	// internalGrpcMiddleware "bp/internal/middleware/rpc"
	"go.uber.org/zap"
	"google.golang.org/grpc"
)

// BackendApiServer :grpc server proxy of backend
type BackendApiServer struct {
	slog      *zap.SugaredLogger
	offImp    *off_imp.OffBackendApiImp
	couponImp *coupon_imp.CouponBackendApiImp
}

// NewBackendApiServer initialization
func NewBackendApiServer(
	s *grpc.Server,
	slog *zap.SugaredLogger,
	pgdao *db.PgDao,
	vars *conf.VarsSection,
	entityHub *entity.EntityHub,
	comHub *com.ComHub,
	// proxy *client.GrpcClientProxy,
	// adp *cache.Adapter,
) (bs *BackendApiServer) {
	bs = &BackendApiServer{
		slog: slog.With("module", "BackendApiServer"),
	}

	bs.offImp = off_imp.New(slog, pgdao, vars, s, entityHub, comHub)
	bs.couponImp = coupon_imp.New(slog, pgdao, vars, s, entityHub, comHub)

	return
}

// NewContextLogger create a SugaredLogger with contextvalue
// func (s *BackendApiServer) NewContextLogger(ctx context.Context) *zap.SugaredLogger {
// 	return util.NewContextLogger(ctx, s.slog)
// }

// func (s *BackendApiServer) getCtxToken(ctx context.Context) (token *util.BilinToken) {
// 	token = ctx.Value(util.BilinTokenKey{}).(*util.BilinToken)
// 	return
// }

// func (s *BackendApiServer) getCtxPager(ctx context.Context) (token *util.Pager) {
// 	token = ctx.Value(util.PagerKey{}).(*util.Pager)
// 	return
// }
